<!DOCTYPE HTML>
<html lang="zh-cn" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>重复的轮子 | Webpack 中文指南</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.5.2">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="gitbook/style.css">
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-prism/prism.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-ad/plugin.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="./start.html" />
    
    
    <link rel="prev" href="./module-system.html" />
    

        
    </head>
    <body>
        
        
    <div class="book" data-level="1.2" data-chapter-title="重复的轮子" data-filepath="what-is-webpack.md" data-basepath="." data-revision="Wed May 03 2017 21:11:01 GMT+0800 (CST)">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="./index.html">
                
                        <i class="fa fa-check"></i>
                        
                        介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="preface.html">
            
                
                    <a href="./preface.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        前言
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="module-system.html">
            
                
                    <a href="./module-system.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        模块系统
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="1.2" data-path="what-is-webpack.html">
            
                
                    <a href="./what-is-webpack.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        重复的轮子
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="start.html">
            
                
                    <a href="./start.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        准备开始
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="install.html">
            
                
                    <a href="./install.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        安装
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="usage.html">
            
                
                    <a href="./usage.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="loader.html">
            
                
                    <a href="./loader.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        Loader
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="configuration.html">
            
                
                    <a href="./configuration.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        配置文件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="plugin.html">
            
                
                    <a href="./plugin.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        插件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="development.html">
            
                
                    <a href="./development.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        开发环境
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="troubleshooting.html">
            
                
                    <a href="./troubleshooting.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.</b>
                        
                        故障处理
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="advanced.html">
            
                
                    <a href="./advanced.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        高级
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="commonjs.html">
            
                
                    <a href="./commonjs.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        CommonJS 规范
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="amd.html">
            
                
                    <a href="./amd.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        AMD 规范
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="reference.html">
            
                
                    <a href="./reference.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        参考链接
                    </a>
            
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    本书使用 GitBook 发布
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="./" >Webpack 中文指南</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x4EC0;&#x4E48;&#x662F;-webpack">&#x4EC0;&#x4E48;&#x662F; Webpack</h1>
<p>Webpack &#x662F;&#x4E00;&#x4E2A;&#x6A21;&#x5757;&#x6253;&#x5305;&#x5668;&#x3002;&#x5B83;&#x5C06;&#x6839;&#x636E;&#x6A21;&#x5757;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#x8FDB;&#x884C;&#x9759;&#x6001;&#x5206;&#x6790;&#xFF0C;&#x7136;&#x540E;&#x5C06;&#x8FD9;&#x4E9B;&#x6A21;&#x5757;&#x6309;&#x7167;&#x6307;&#x5B9A;&#x7684;&#x89C4;&#x5219;&#x751F;&#x6210;&#x5BF9;&#x5E94;&#x7684;&#x9759;&#x6001;&#x8D44;&#x6E90;&#x3002;</p>
<p><img src="images/what-is-webpack.png" alt="&#x4EC0;&#x4E48;&#x662F;webpack"></p>
<h1 id="&#x4E3A;&#x4EC0;&#x4E48;&#x91CD;&#x590D;&#x9020;&#x8F6E;&#x5B50;">&#x4E3A;&#x4EC0;&#x4E48;&#x91CD;&#x590D;&#x9020;&#x8F6E;&#x5B50;</h1>
<p>&#x5E02;&#x9762;&#x4E0A;&#x5DF2;&#x7ECF;&#x5B58;&#x5728;&#x7684;&#x6A21;&#x5757;&#x7BA1;&#x7406;&#x548C;&#x6253;&#x5305;&#x5DE5;&#x5177;&#x5E76;&#x4E0D;&#x9002;&#x5408;&#x5927;&#x578B;&#x7684;&#x9879;&#x76EE;&#xFF0C;&#x5C24;&#x5176;&#x5355;&#x9875;&#x9762; Web &#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x3002;&#x6700;&#x7D27;&#x8FEB;&#x7684;&#x539F;&#x56E0;&#x662F;&#x5982;&#x4F55;&#x5728;&#x4E00;&#x4E2A;&#x5927;&#x89C4;&#x6A21;&#x7684;&#x4EE3;&#x7801;&#x5E93;&#x4E2D;&#xFF0C;&#x7EF4;&#x62A4;&#x5404;&#x79CD;&#x6A21;&#x5757;&#x8D44;&#x6E90;&#x7684;&#x5206;&#x5272;&#x548C;&#x5B58;&#x653E;&#xFF0C;&#x7EF4;&#x62A4;&#x5B83;&#x4EEC;&#x4E4B;&#x95F4;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#xFF0C;&#x5E76;&#x4E14;&#x65E0;&#x7F1D;&#x7684;&#x5C06;&#x5B83;&#x4EEC;&#x6574;&#x5408;&#x5230;&#x4E00;&#x8D77;&#x751F;&#x6210;&#x9002;&#x5408;&#x6D4F;&#x89C8;&#x5668;&#x7AEF;&#x8BF7;&#x6C42;&#x52A0;&#x8F7D;&#x7684;&#x9759;&#x6001;&#x8D44;&#x6E90;&#x3002;</p>
<p>&#x8FD9;&#x4E9B;&#x5DF2;&#x6709;&#x7684;&#x6A21;&#x5757;&#x5316;&#x5DE5;&#x5177;&#x5E76;&#x4E0D;&#x80FD;&#x5F88;&#x597D;&#x7684;&#x5B8C;&#x6210;&#x5982;&#x4E0B;&#x7684;&#x76EE;&#x6807;&#xFF1A;</p>
<ul>
<li>&#x5C06;&#x4F9D;&#x8D56;&#x6811;&#x62C6;&#x5206;&#x6210;&#x6309;&#x9700;&#x52A0;&#x8F7D;&#x7684;&#x5757;</li>
<li>&#x521D;&#x59CB;&#x5316;&#x52A0;&#x8F7D;&#x7684;&#x8017;&#x65F6;&#x5C3D;&#x91CF;&#x5C11;</li>
<li>&#x5404;&#x79CD;&#x9759;&#x6001;&#x8D44;&#x6E90;&#x90FD;&#x53EF;&#x4EE5;&#x89C6;&#x4F5C;&#x6A21;&#x5757;</li>
<li>&#x5C06;&#x7B2C;&#x4E09;&#x65B9;&#x5E93;&#x6574;&#x5408;&#x6210;&#x6A21;&#x5757;&#x7684;&#x80FD;&#x529B;</li>
<li>&#x53EF;&#x4EE5;&#x81EA;&#x5B9A;&#x4E49;&#x6253;&#x5305;&#x903B;&#x8F91;&#x7684;&#x80FD;&#x529B;</li>
<li>&#x9002;&#x5408;&#x5927;&#x9879;&#x76EE;&#xFF0C;&#x65E0;&#x8BBA;&#x662F;&#x5355;&#x9875;&#x8FD8;&#x662F;&#x591A;&#x9875;&#x7684; Web &#x5E94;&#x7528;</li>
</ul>
<h1 id="webpack-&#x7684;&#x7279;&#x70B9;">Webpack &#x7684;&#x7279;&#x70B9;</h1>
<p>Webpack &#x548C;&#x5176;&#x4ED6;&#x6A21;&#x5757;&#x5316;&#x5DE5;&#x5177;&#x6709;&#x4EC0;&#x4E48;&#x533A;&#x522B;&#x5462;&#xFF1F;</p>
<h3 id="&#x4EE3;&#x7801;&#x62C6;&#x5206;">&#x4EE3;&#x7801;&#x62C6;&#x5206;</h3>
<p>Webpack &#x6709;&#x4E24;&#x79CD;&#x7EC4;&#x7EC7;&#x6A21;&#x5757;&#x4F9D;&#x8D56;&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x540C;&#x6B65;&#x548C;&#x5F02;&#x6B65;&#x3002;&#x5F02;&#x6B65;&#x4F9D;&#x8D56;&#x4F5C;&#x4E3A;&#x5206;&#x5272;&#x70B9;&#xFF0C;&#x5F62;&#x6210;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x5757;&#x3002;&#x5728;&#x4F18;&#x5316;&#x4E86;&#x4F9D;&#x8D56;&#x6811;&#x540E;&#xFF0C;&#x6BCF;&#x4E00;&#x4E2A;&#x5F02;&#x6B65;&#x533A;&#x5757;&#x90FD;&#x4F5C;&#x4E3A;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x88AB;&#x6253;&#x5305;&#x3002;</p>
<h3 id="loader">Loader</h3>
<p>Webpack &#x672C;&#x8EAB;&#x53EA;&#x80FD;&#x5904;&#x7406;&#x539F;&#x751F;&#x7684; JavaScript &#x6A21;&#x5757;&#xFF0C;&#x4F46;&#x662F; loader &#x8F6C;&#x6362;&#x5668;&#x53EF;&#x4EE5;&#x5C06;&#x5404;&#x79CD;&#x7C7B;&#x578B;&#x7684;&#x8D44;&#x6E90;&#x8F6C;&#x6362;&#x6210; JavaScript &#x6A21;&#x5757;&#x3002;&#x8FD9;&#x6837;&#xFF0C;&#x4EFB;&#x4F55;&#x8D44;&#x6E90;&#x90FD;&#x53EF;&#x4EE5;&#x6210;&#x4E3A; Webpack &#x53EF;&#x4EE5;&#x5904;&#x7406;&#x7684;&#x6A21;&#x5757;&#x3002;</p>
<h3 id="&#x667A;&#x80FD;&#x89E3;&#x6790;">&#x667A;&#x80FD;&#x89E3;&#x6790;</h3>
<p>Webpack &#x6709;&#x4E00;&#x4E2A;&#x667A;&#x80FD;&#x89E3;&#x6790;&#x5668;&#xFF0C;&#x51E0;&#x4E4E;&#x53EF;&#x4EE5;&#x5904;&#x7406;&#x4EFB;&#x4F55;&#x7B2C;&#x4E09;&#x65B9;&#x5E93;&#xFF0C;&#x65E0;&#x8BBA;&#x5B83;&#x4EEC;&#x7684;&#x6A21;&#x5757;&#x5F62;&#x5F0F;&#x662F; CommonJS&#x3001; AMD &#x8FD8;&#x662F;&#x666E;&#x901A;&#x7684; JS &#x6587;&#x4EF6;&#x3002;&#x751A;&#x81F3;&#x5728;&#x52A0;&#x8F7D;&#x4F9D;&#x8D56;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5141;&#x8BB8;&#x4F7F;&#x7528;&#x52A8;&#x6001;&#x8868;&#x8FBE;&#x5F0F; <code>require(&quot;./templates/&quot; + name + &quot;.jade&quot;)</code>&#x3002;</p>
<h3 id="&#x63D2;&#x4EF6;&#x7CFB;&#x7EDF;">&#x63D2;&#x4EF6;&#x7CFB;&#x7EDF;</h3>
<p>Webpack &#x8FD8;&#x6709;&#x4E00;&#x4E2A;&#x529F;&#x80FD;&#x4E30;&#x5BCC;&#x7684;&#x63D2;&#x4EF6;&#x7CFB;&#x7EDF;&#x3002;&#x5927;&#x591A;&#x6570;&#x5185;&#x5BB9;&#x529F;&#x80FD;&#x90FD;&#x662F;&#x57FA;&#x4E8E;&#x8FD9;&#x4E2A;&#x63D2;&#x4EF6;&#x7CFB;&#x7EDF;&#x8FD0;&#x884C;&#x7684;&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x5F00;&#x53D1;&#x548C;&#x4F7F;&#x7528;&#x5F00;&#x6E90;&#x7684; Webpack &#x63D2;&#x4EF6;&#xFF0C;&#x6765;&#x6EE1;&#x8DB3;&#x5404;&#x5F0F;&#x5404;&#x6837;&#x7684;&#x9700;&#x6C42;&#x3002;</p>
<h3 id="&#x5FEB;&#x901F;&#x8FD0;&#x884C;">&#x5FEB;&#x901F;&#x8FD0;&#x884C;</h3>
<p>Webpack &#x4F7F;&#x7528;&#x5F02;&#x6B65; I/O &#x548C;&#x591A;&#x7EA7;&#x7F13;&#x5B58;&#x63D0;&#x9AD8;&#x8FD0;&#x884C;&#x6548;&#x7387;&#xFF0C;&#x8FD9;&#x4F7F;&#x5F97; Webpack &#x80FD;&#x591F;&#x4EE5;&#x4EE4;&#x4EBA;&#x96BE;&#x4EE5;&#x7F6E;&#x4FE1;&#x7684;&#x901F;&#x5EA6;&#x5FEB;&#x901F;&#x589E;&#x91CF;&#x7F16;&#x8BD1;&#x3002;</p>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="./module-system.html" class="navigation navigation-prev " aria-label="Previous page: 模块系统"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="./start.html" class="navigation navigation-next " aria-label="Next page: 准备开始"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="gitbook/app.js"></script>

    
    <script src="gitbook/plugins/gitbook-plugin-github/plugin.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-editlink/plugin.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-baidu/plugin.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-ad/plugin.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"github":{"url":"https://github.com/zhaoda/webpack-handbook"},"editlink":{"base":"https://github.com/zhaoda/webpack-handbook/edit/master/content","label":"编辑本页","multilingual":false},"baidu":{"token":"a9787f0ab45d5e237bab522431d0a7ec"},"sharing":{"weibo":true,"twitter":false,"facebook":false,"google":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"ad":{"contentBottom":"%3Cscript%20async%20src%3D%22//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js%22%3E%3C/script%3E%3C%21--%20%u81EA%u9002%u5E94%u9AD8%u53CD%u5DEE%u9ED1%u8272%20--%3E%3Cins%20class%3D%22adsbygoogle%22%20style%3D%22display%3Ablock%22%20data-ad-client%3D%22ca-pub-9798300025848807%22%20data-ad-slot%3D%228607007877%22%20data-ad-format%3D%22auto%22%3E%3C/ins%3E%3Cscript%3E%28adsbygoogle%20%3D%20window.adsbygoogle%20%7C%7C%20%5B%5D%29.push%28%7B%7D%29%3B%3C/script%3E%3C/p%3E%3Cdiv%20id%3D%22disqus_thread%22%3E%3C/div%3E%3Cscript%3E%28function%28%29%20%7Bvar%20d%20%3D%20document%2C%20s%20%3D%20d.createElement%28%27script%27%29%3Bs.src%20%3D%20%27//webpack-handbook.disqus.com/embed.js%27%3Bs.setAttribute%28%27data-timestamp%27%2C%20+new%20Date%28%29%29%3B%28d.head%20%7C%7C%20d.body%29.appendChild%28s%29%3B%7D%29%28%29%3B%3C/script%3E%3Cnoscript%3EPlease%20enable%20JavaScript%20to%20view%20the%20%3Ca%20href%3D%22https%3A//disqus.com/%3Fref_noscript%22%20rel%3D%22nofollow%22%3Ecomments%20powered%20by%20Disqus.%3C/a%3E%3C/noscript%3E"},"sitemap":{"hostname":"http://zhaoda.net/"},"prism":{},"highlight":{},"search":{},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        <script>var _hmt = _hmt || [];(function() {var hm = document.createElement('script');hm.src = '//hm.baidu.com/hm.js?a9787f0ab45d5e237bab522431d0a7ec';var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(hm, s);})();</script>
    </body>
    
</html>
